//
//  CommunityInteractionTableViewCell.m
//  ECBBusinessCamp
//
//  Created by rimi on 16/6/22.
//  Copyright © 2016年 邓毕华. All rights reserved.
//

#import "CommunityInteractionTableViewCell.h"

#define LABEL_TEXTCOLOR RGB_COLOR(80, 80, 80, 1)

@implementation CommunityInteractionTableViewCell

#pragma mark 🌷🌷🌷life cycle🌷🌷🌷
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        // 修改选中效果
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        // 添加视图
        [self addSubview:self.backgroundColorView];
        [_backgroundColorView addSubview:self.headImageView];
        [_backgroundColorView addSubview:self.titleLabel];
        [_backgroundColorView addSubview:self.contentLabel];
        [_backgroundColorView addSubview:self.nameLabel];
        [_backgroundColorView addSubview:self.releaseDateLabel];
        
        // 自动布局
        [_backgroundColorView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(self).multipliedBy(0.94);
            make.height.equalTo(self).multipliedBy(0.85);
            make.centerX.equalTo(self);
            make.top.offset(0);
        }];
        [_headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.equalTo(self.mas_height).multipliedBy(0.6);
            make.top.left.offset(SCREEN_WIDTH * 0.012);
        }];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(SCREEN_WIDTH * 0.015);
            make.left.equalTo(_headImageView.mas_right).offset(SCREEN_WIDTH * 0.024);
        }];
        [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(_backgroundColorView).multipliedBy(0.8);
            make.left.equalTo(_titleLabel);
            make.top.equalTo(_headImageView.mas_centerY);
        }];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headImageView);
            make.top.equalTo(_headImageView.mas_bottom).offset(SCREEN_HEIGHT * 0.01);
        }];
        [_releaseDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_nameLabel);
            make.right.offset(SCREEN_WIDTH * -0.05);
        }];
    }
    return self;
}

#pragma mark 🌷🌷🌷getters and setters🌷🌷🌷
- (UIView *)backgroundColorView {
    if (!_backgroundColorView) {
        _backgroundColorView = [[UIView alloc] init];
        _backgroundColorView.backgroundColor = RGB_COLOR(239, 239, 239, 1);
    }
    return _backgroundColorView;
}
- (UIImageView *)headImageView {
    if (!_headImageView) {
        _headImageView = [[UIImageView alloc] init];
    }
    return _headImageView;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:28];
    }
    return _titleLabel;
}
- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.numberOfLines = 2;
        _contentLabel.font = [UIFont systemFontOfSize:25];
        _contentLabel.textColor = LABEL_TEXTCOLOR;
    }
    return _contentLabel;
}
- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.font = [UIFont systemFontOfSize:25];
        _nameLabel.textColor = LABEL_TEXTCOLOR;
    }
    return _nameLabel;
}
- (UILabel *)releaseDateLabel {
    if (!_releaseDateLabel) {
        _releaseDateLabel = [[UILabel alloc] init];
        _releaseDateLabel.textColor = LABEL_TEXTCOLOR;
        _releaseDateLabel.font = [UIFont systemFontOfSize:18];
    }
    return _releaseDateLabel;
}

@end
